package com.baikeyang.common.netease;

import cn.hutool.http.Header;
import cn.hutool.http.HttpRequest;

import java.util.Map;

public class ApiUtil {

  private static String servser_url = "http://music.163.com";

  public static String httpPost(String url, String param) {
    String result = HttpRequest.post(servser_url + url)
      .header(Header.ACCEPT, "*/*")
      .header(Header.ACCEPT_LANGUAGE, "zh-CN,zh;q=0.8,gl;q=0.6,zh-TW;q=0.4")
      .header(Header.CONNECTION, "keep-alive")
      .header(Header.CONTENT_TYPE, "application/x-www-form-urlencoded")
      .header(Header.REFERER, "http://music.163.com")
      .header(Header.HOST, "music.163.com")
      .header(Header.COOKIE, "appver=2.0.2;\\n")
      .header(Header.USER_AGENT, "Mozilla/5.0 (iPhone; CPU iPhone OS 9_1 like Mac OS X) AppleWebKit/602.1.46 (KHTML, like Gecko) Version/9.0 Mobile/13B143 Safari/602.1")
      .form(ParamUtil.convertParam(param)).timeout(20000)//超时，毫秒
      .execute().body();
    return result;
  }

}
